package com.zy.explore.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;
import tk.mybatis.spring.annotation.MapperScan;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * description 应用启动入口类
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2021年12月21日13时31分11秒
 */
@Slf4j
@EnableDiscoveryClient
@SpringBootApplication
@EnableFeignClients(basePackages = {"com.zy.explore.web.*"})
@MapperScan(basePackages = {"com.zy.explore.*.dao"})
@ComponentScan(basePackages = {"com.zy.explore"})
public class DddWebApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(DddWebApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }

        log.info("\n----------------------------------------------------------\n" +
                "DddWebApplication is running! Access URLs:\n\t" +
                "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "Swagger访问网址: \thttp://localhost:" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
    }

}